package com.ymatou.iapi.godmch.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godmch.parameter.condition;
import com.ymatou.iapi.godmch.parameter.getAgentConditionLevelBean;
import com.ymatou.iapi.godmch.parameter.setAgentConditionLevelBean;
import com.ymatou.iapi.godmch.service.getAgentConditionLevelCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*获取代理价按条件加价优先级
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getAgentConditionLevel{
	private static getAgentConditionLevelBean bean;
	private static getAgentConditionLevelCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取代理价按条件加价优先级");
	}

	@Before
	public void caseUp() {
		bean=new getAgentConditionLevelBean();
		call=new getAgentConditionLevelCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getAgentConditionLevel_001() {
		Logger.start(true,"获取代理价按条件加价优先级-一条类型-返回成功");
		try {
			Integer mchId=GodmchManageCallService.CreateSellerMch();
			setAgentConditionLevelBean agentLevelBean=GodmchManageCallService.initSetAgentConditionLevelBean(mchId);
			GodmchManageCallService.setAgentConditionLevel(agentLevelBean);
			bean.setMchId(mchId);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getAgentConditionLevel_002() {
		Logger.start(true,"获取代理价按条件加价优先级-设置两条类型-返回成功");
		try {
			Integer mchId=GodmchManageCallService.CreateSellerMch();
			setAgentConditionLevelBean agentLevelBean=GodmchManageCallService.initSetAgentConditionLevelBean(mchId);
			
			List<condition> lst=new ArrayList<condition>();
		    //添加一条
   		    condition con=new condition();
   		    con.setConditionType(5);
   		    con.setConditionLevel(2);
   		    lst.add(con);
   		    //添加两条
   		    con=new condition();
   		    con.setConditionType(3);
   		    con.setConditionLevel(1);
   		    lst.add(con);
   		    agentLevelBean.setList(lst);
	   		
			GodmchManageCallService.setAgentConditionLevel(agentLevelBean);
			bean.setMchId(mchId);
			call.setData(bean);
			call.callService();		
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getAgentConditionLevel_004() {
		Logger.start(true,"获取代理价按条件加价优先级-商户id为空-返回失败");
		try {
	
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}